package com.gongj.rabbit.workqueue.demo1;

import com.gongj.rabbit.utils.RabbitMQUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;

import java.io.IOException;

/**
 * 工作队列
 * 生产者
 */
public class Provider {
    public static void main(String[] args) throws Exception {
        Connection conn = RabbitMQUtil.createConn();

        Channel channel = conn.createChannel();

        channel.queueDeclare("work", false, false, false, null);

        for (int i = 0; i < 20; i++) {
            channel.basicPublish("","work",null,(i + "hello word queue").getBytes());
        }
        RabbitMQUtil.closeConn(channel,conn);
    }
}
